package com.fanqiechaodan.interpreter;

/**
 * @author fanqiechaodan
 * @Classname AddExpression
 * @Description 非终结符表达式;解释加法
 */
public class AddExpression implements Expression {

    /**
     * 左表达式
     */
    private Expression leftExpression;

    /**
     * 右表达式
     */
    private Expression rightExpression;

    public AddExpression(Expression leftExpression, Expression rightExpression) {
        this.leftExpression = leftExpression;
        this.rightExpression = rightExpression;
    }

    /**
     * 解释表达式
     *
     * @return
     */
    @Override
    public int interpreter() {
        return leftExpression.interpreter() + rightExpression.interpreter();
    }
}
